import React, { Component } from 'react';
import { Form, Button, Input, TextArea } from 'antd-mobile'
import { connect  } from 'react-redux'
import { addList } from '../../../store/actions'
import logo from '../../../logo192.png'
class Index extends Component {
	handleSubmit(value) {
		value.id = new Date().getTime()
		value.url = logo
		console.log(value)

		this.props.dispatch(addList(value))
	}
	render() {
		return (
			<div>
				<Form
					onFinish={ value => this.handleSubmit(value) }
					layout='horizontal'
					footer={
						<Button block type='submit' color='primary'>
							提交
						</Button>
					}
				>
					<Form.Item
						name='title'
						label='标题'
						rules={[{ required: true, message: '标题不能为空' }]}
					>
						<Input placeholder='请输入标题' />
					</Form.Item>
					<Form.Item
						name='price'
						label='单价'
						rules={[{ required: true, message: '单价不能为空' }]}
					>
						<Input placeholder='请输入单价' />
					</Form.Item>
					<Form.Item name='desc' label='描述'>
						<TextArea placeholder='请输入描述' maxLength={100} rows={4} />
					</Form.Item>
				</Form>
			</div>
		);
	}
}

export default connect(null, dispatch => ({ dispatch }))(Index);
